package com.denlaku.longan.controller;

import com.denlaku.longan.http.Return;
import com.denlaku.longan.vo.CustomApi;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

/**
 * @author tianx
 */
public interface CustomPageController {
    /**
     * 根据ID获取资源
     *
     * @param tenantId 租户ID
     * @param id 资源ID
     * @param response 响应对象
     */
    @GetMapping("/page/{tenantId}/{id}/")
    void source(@PathVariable("tenantId") Long tenantId, @PathVariable("id") Long id,
            HttpServletResponse response);

    /**
     * 根据ID及路径获取资源
     *
     * @param tenantId 租户ID
     * @param id 资源ID
     * @param request 请求对象
     * @param response 响应对象
     */
    @GetMapping(value = {"/page/{tenantId}/{id}/**"})
    void source(@PathVariable("tenantId") Long tenantId, @PathVariable("id") Long id,
            HttpServletRequest request, HttpServletResponse response);

    /**
     * 获取自定义API数据
     *
     * @param customApis 自定义API
     * @return 响应对象
     */
    @PostMapping("/fetches")
    @ResponseBody
    Return<Map<Long, List<Map<String, Object>>>> fetches(@RequestBody List<CustomApi> customApis);

}
